//
//  attentionDoctorsCell.m
//  FastDoctor
//
//  Created by 云卷云舒丶 on 16/7/8.
//  Copyright © 2016年 sc. All rights reserved.
//

#import "attentionDoctorsCell.h"
#import <UIImageView+WebCache.h>
@interface attentionDoctorsCell()

//定义属性 传递匹配度属性
@property(nonatomic,strong)UILabel *TFlabel;
////院名doctor_hospital_name

////医生名doctor_name
////医生头像doctor_portrait
////医生职位doctor_title_name
//operation_count
////花flower
////旗帜banner
////匹配度
//@property (nonatomic, copy) NSNumber *accuracy;
@end
@implementation attentionDoctorsCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    [self setupUI];
    
    return self;
}


//设置约束
-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    
    [_grayView makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.offset(0);
        make.leading.offset(0);
        make.width.equalTo(self.contentView.bounds.size.width);
        make.height.equalTo(@15);
    }];
    
    
    [_docImg makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.grayView.bottom).offset(12);
        make.bottom.offset(-10);
        make.leading.offset(10);
        make.width.equalTo(_docImg.height);
    }];
    
    
    
    [_lb_name makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_docImg.right).offset(20);
        make.top.equalTo(_docImg.top).offset(5);
        make.width.equalTo(@90);
        make.height.equalTo(@20);
        
    }];
    
    [_lb_post makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_lb_name.right).offset(0);
        make.top.equalTo(_lb_name.top).offset(3);
        
    }];
    
    [_lb_hospital makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(_lb_name.leading).offset(0);
        make.top.equalTo(_lb_name.bottom).offset(10);
    }];
    
    [_operation makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_lb_hospital.bottom).offset(10);
        make.left.equalTo(_docImg.right).offset(20);
        make.width.equalTo(@40);
        make.height.equalTo(@10);
    }];
    
    [_flower makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_operation.top).offset(0);
        make.left.equalTo(_operation.right).offset(10);
        make.width.equalTo(@40);
        make.height.equalTo(@10);
    }];
    
    [_banner makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(_flower.top).offset(0);
        make.left.equalTo(_flower.right).offset(10);
        make.width.equalTo(@40);
        make.height.equalTo(@10);
    }];
    
    [_rightImg makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.offset(10);
        make.right.offset(-30);
        make.width.equalTo(@38);
        make.height.equalTo(@45);
    }];
    
}
//初始化界面
-(void)setupUI{
    
    self.TFlabel = [[UILabel alloc]init];
    
    
    UIView *view = [[UIView alloc]init];
    self.grayView = view;
    [self.grayView setBackgroundColor:[UIColor colorWithRed:247/265.0 green:247/265.0 blue:247/265.0 alpha:1.0]];
    [self.contentView addSubview:_grayView];
    
    HeadImageView *imageview = [[HeadImageView alloc]init];
    self.docImg = imageview;
    
   
    
    [self.contentView addSubview:_docImg];
    
   
    
    UILabel *label1 = [[UILabel alloc]init];
    self.lb_name = label1;
    [self.contentView addSubview:_lb_name];
    
    UILabel *label2 = [[UILabel alloc]init];
    self.lb_post = label2;
    [self.contentView addSubview:label2];
    
    
    UILabel *label3 = [[UILabel alloc]init];
    self.lb_hospital = label3;
    [self.contentView addSubview:label3];
    
    UIButton *btn1 = [[UIButton alloc]init];
    self.operation = btn1;
    [self.contentView addSubview:_operation];
    
    UIButton *btn2 = [[UIButton alloc]init];
    self.flower = btn2;
    [self.contentView addSubview:_flower];
    
    UIButton *btn3 = [[UIButton alloc]init];
    self.banner = btn3;
    [self.contentView addSubview:_banner];
    
    //定义匹配度imageview
    UIImageView *rightImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pipeidu"]];
    self.rightImg = rightImg;
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(rightImg.bounds.origin.x / 2, 6, 38, 10)];
    label4.text = @"匹配度";
    [label4 setFont:[UIFont systemFontOfSize:10]];
    [label4 setTextAlignment:NSTextAlignmentCenter];
    [label4 setTextColor:[UIColor whiteColor]];
    
    UILabel *matchLabel = [[UILabel alloc]initWithFrame:CGRectMake(rightImg.bounds.origin.x / 2, 20, 38, 10)];
    [matchLabel setFont:[UIFont systemFontOfSize:10]];
    [matchLabel setTextAlignment:NSTextAlignmentCenter];
    [matchLabel setTextColor:[UIColor whiteColor]];
    
    //匹配度,不是赋值操作!!控件怎么能传递数据!!
    self.TFlabel = matchLabel;
    
    [self.rightImg addSubview:label4];
    [self.rightImg addSubview:matchLabel];
    [self.contentView addSubview:_rightImg];
    
    
}
//设置数据
-(void)setModel:(attentionDoctorsModel *)model{
    
    _model = model;
    

    [self.docImg sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait] placeholderImage:[UIImage imageNamed:@"name"]];

    self.lb_name.text = model.doctor_name;
    [self.lb_name setFont:[UIFont systemFontOfSize:17]];
    
    self.lb_post.text = model.doctor_title_name;
    [self.lb_post setTextColor:[UIColor colorWithRed:202/265.0 green:202/265.0 blue:202/265.0 alpha:1.0]];
    [self.lb_post sizeToFit];
    [self.lb_post setFont:[UIFont systemFontOfSize:15]];
    
    self.lb_hospital.text = model.doctor_hospital_name;
    [self.lb_hospital setTextColor:[UIColor colorWithRed:202/265.0 green:202/265.0 blue:202/265.0 alpha:1.0]];
    [self.lb_hospital setFont:[UIFont systemFontOfSize:15]];
    
    [self.flower setImage:[UIImage imageNamed:@"xianhua"] forState:UIControlStateNormal];
    [self.flower setTitle:[NSString stringWithFormat:@"%@",model.flower] forState:UIControlStateNormal];
    [self.flower setTitleColor:kThemeColor forState:UIControlStateNormal];
    UIEdgeInsets edge = {0,10,0,0};
    [self.flower setTitleEdgeInsets:edge];
    self.flower.enabled = NO;
    
    [self.operation setImage:[UIImage imageNamed:@"yuyueliang"] forState:UIControlStateNormal];
    [self.operation setTitle:[NSString stringWithFormat:@"%@",model.operation_count] forState:UIControlStateNormal];
    [self.operation setTitleColor:kThemeColor forState:UIControlStateNormal];
    UIEdgeInsets edge2 = {0,10,0,0};
    [self.operation setTitleEdgeInsets:edge2];
    self.operation.enabled = NO;
    
    
    [self.banner setImage:[UIImage imageNamed:@"jinqi"] forState:UIControlStateNormal];
    [self.banner setTitle:[NSString stringWithFormat:@"%@",model.banner] forState:UIControlStateNormal];
    [self.banner setTitleColor:kThemeColor forState:UIControlStateNormal];
    UIEdgeInsets edge3 = {0,10,0,0};
    [self.banner setTitleEdgeInsets:edge3];
    self.banner.enabled = NO;
    
    //获取匹配度
    self.TFlabel.text = [NSString stringWithFormat:@"%@",model.accuracy];
    
    
}


@end
